package com.leoman.plz_p.adapter;

import android.content.Context;

import com.leoman.plz_p.R;
import com.leoman.plz_p.module.bean.MissionDetailBean;

import cn.com.corelib.utils.adapter.BaseAdapterHelper;
import cn.com.corelib.utils.adapter.normal.QuickAdapter;

/**
 * Created by guoh on 2018/7/9.
 */
public class MissionDetailAdapter extends QuickAdapter<MissionDetailBean> {


    public MissionDetailAdapter(Context context) {
        super(context, R.layout.item_mission_detail);
    }

    @Override
    protected void convert(final BaseAdapterHelper helper, MissionDetailBean item, final int position) {
        helper.setText(R.id.tv_title_name,item.getName());
        switch (item.getStatus()){
            case 1:
                helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_zero_to_four);
                break;
            case 2:
                helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_one_to_one);
                break;
        }

        MissionClassAdapter adapter=new MissionClassAdapter(context);
        adapter.replaceAll(item.getLists());
        helper.setAdapter(R.id.ls_class,adapter);
        adapter.setOnItemClick(new MissionClassAdapter.onItemClick() {
            @Override
            public void onVideoClick(int parentPosition, int pos) {
                if (onItemClick!=null){
                    onItemClick.onVideoClick(position,parentPosition,pos);
                }
            }

            @Override
            public void onTestClick(int parentPosition, int pos) {
                if (onItemClick!=null){
                    onItemClick.onTestClick(position,parentPosition,pos);
                }
            }
        });
    }

    public void setOnItemClick(onItemClick onItemClick) {
        this.onItemClick = onItemClick;
    }

    private onItemClick onItemClick;

    public interface onItemClick{
        void onVideoClick(int grandpaPosition, int parentPosition, int position);
        void onTestClick(int grandpaPosition, int parentPosition, int position);
    }
}
